#include<bits/stdc++.h>
using namespace std;
#define PII pair<int,int>
vector<int>all;
vector<PII>add,wen;

const int N=1e5+10;
int sum[N],a[N];

int find(int x){
	int l=0,r=all.size()-1;
	while(l<r){
		int mid=l+r>>1;
		if(all[mid]>=x)r=mid;
		else l=mid+1;
	}
	return r+1;
} 

int main(){
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;++i){
		int pos,val;
		cin>>pos>>val;
		add.push_back({pos,val});
		all.push_back(pos);
	}
	for(int i=1;i<=m;++i){
		int l,r;
		cin>>l>>r;
		wen.push_back({l,r});
		all.push_back(l);
		all.push_back(r);
	}
	sort(all.begin(),all.end());
	all.erase(unique(all.begin(),all.end()),all.end());
	for(auto i:add){
		int x=find(i.first);
		a[x]+=i.second;
	}
	for(int i=1;i<=all.size();++i)sum[i]=sum[i-1]+a[i];
	for(auto i:wen){
		int l=find(i.first);
		int r=find(i.second);
		cout<<sum[r]-sum[l-1]<<endl;
	}
	return 0;
}
